Repository navigation
fix(auth): treat only approved users as signed in - #143
Merged
Merged
Conversation
A valid session cookie was treated as authorization. The request-access flow issues a temporary session to unapproved GitHub users, and revoked users may hold old cookies; sessionReader set `user` for all of them, and the approval check lived only in requireAuth(accessStore) on /admin, /new, /settings and /forms. Routes gated on `user` presence or ownership — POST /:owner/:slug/fork (and edit/authoring on the fork), compare comments, and the project-scoped /:owner/:slug/forms router (mounted without an access store) — admitted pending, revoked and no-entry users. sessionReader(accessStore) now resolves access once per request: only an approved entry sets `user`. Pending/no-entry sessions are exposed as `requester`, read only by the request-access pages; revoked cookies are cleared. ALLOWED_USERS logins with no row (cookie minted on another deployment) are treated as approved. requireAuth() no longer takes a store; the unused accessStore deps on the forms and settings routers are removed. Threat model updated. Pot-Run: 7979
3 of 4 tasks
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Security fix for a hole that is live on
main.A valid session cookie was treated as authorization. Any GitHub user who signs in gets a session cookie, even before they are approved: the request-access flow issues it to unapproved requesters. Revoked users may also still hold valid cookies. The approval check only ran in
requireAuth(accessStore)on/admin,/new,/settingsand/forms. Everything gated on "signed in" or "is owner" let unapproved users through.Confirmed with failing tests using forged cookies for pending, revoked and no-entry users:
POST /:owner/:slug/forkworked for these users. The edit and authoring routes on the resulting fork check only ownership, so they could also run the paid Bedrock pipelines.POST /:owner/:slug/compare/:range/commentsaccepted their comments./:owner/:slug/forms/*let them in, because that router was mounted without an access store./newand otherrequireAuth(accessStore)routes let in users with no access row at all.Found while working on #142.
Changes
sessionReader(accessStore)checks access once per request:userrequester, which only the request-access pages readALLOWED_USERSlogins with no row are treated as approved. Each deployment has its own database, so a cookie from another deployment can arrive before the row exists. An explicit revoked row still wins.requireAuth()no longer takes a store. The unusedaccessStoreparameters on the forms and settings routers are removed.Behaviour change to be aware of
A
flexion.us(domain-approved) user browsing a branch deployment they have never signed in to now appears signed out until they sign in there, which creates their row. Before, they were let in with no row.Testing
test/auth-approval-gate.test.ts: fork, compare comment and project form routes reject pending, revoked and no-entry users, and approved users still succeed/and is redirected from/newand from project formsbun run checkpasses (1449 tests)